<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Node</title>
</head>
<body style="font-family: Helvetica,Arial,sans-serif;">
<b>Simple Diffuse Lighting Shader</b><br><br>

Vertex Shader<br><br>

<code>
varying vec3 N, L;<br>
<br>
void main() {<br>
	<br>
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;<br>
	<br>
	N = gl_NormalMatrix * gl_Normal;<br>
	vec4 V = gl_ModelViewMatrix * gl_Vertex;<br><br>
	// use light 0<br>
	L = gl_LightSource[0].position.xyz - V.xyz;<br>
	<br>
	gl_FrontColor = gl_Color;	<br>
}
</code>
<br>
<br>

Fragment Shader<br><br>

<code>
varying vec3 N, L;<br>
<br>
void main() {<br>
	float intensity = max(0.0, dot(normalize(N), normalize(L)));<br>
	gl_FragColor = gl_Color;<br>
	gl_FragColor.rgb *= intensity;<br>
}
</code>
<br>
<br>
</body>
</html>
